$(document).ready(function() {
    $('#link').hide();
    $("#sisdec_situation_id").change(function() {
        //alert("testando")

        $.ajax("resultSearch",
                {
                    type: "GET",
                    data: {id: $(this).val()},
                    //URL: "/estagio/sisdec_occurrences/teste",
                    dataType: 'html',
                    success: function(data) {
                        $('#teste').html(data);
                    }
                });
    });
    $("#btnlink").click(function() {
        //alert($("#procol").val());
        $.getJSON("protocolo", {
            protocol: $("#procol").val()
        }, function(data) {
            var occurrence = "<dt>Protocolo</dt><dd>" + data.SisdecOccurrence.protocolo + "<dd>";
            occurrence += "<dt>Data</dt><dd>" + data.SisdecOccurrence.data_abertura + "<dd>";
            occurrence += "<dt>Descrição</dt><dd>" + data.SisdecOccurrence.descricao + "<dd>";
            occurrence += "<dt>Endereço</dt><dd>" + data.SisdecOccurrence.endereco_occurrence + "<dd>";
            /*$.each(data.SisdecOccurrence, function(i, item) {
             protocolo += "<dd>"+item+"</dd>";
             });*/
            $('#testelist').html(occurrence);
            //$('#divlink').html("</a>").attr("href","/estagio/sisdec_occurrences/view/"+data.SisdecOccurrence.id);
            $('#link').attr("href","/estagio/sisdec_occurrences/view/"+data.SisdecOccurrence.id).show();
        }
        );
    });


});





